<div class="main layui-clear">
    <div class="wrap">
        <div class="content detail">
            <div class="fly-panel detail-box">
                <h1>
                    <?php echo $ques['title'] ?>
                </h1>
                <div class="fly-tip fly-detail-hint">
                <?php if ($ques['status']==0) { ?>
                    <span>
                        <?php echo "未结帖"; ?>
                    </span>
                <?php }else{ ?>
                    <span>
                        <?php echo "已采纳"; ?>
                    </span>
                <?php } ?>
                    <div class="jie-admin-box" data-id="10499">
                    </div>
                    <div class="fly-list-hint">
                        <a href="#comment">
                            <i class="iconfont" title="回答">
                                &#xe60c;
                            </i>
                            <?php echo $ques['answer_num'] ?>
                        </a>
                        <i class="iconfont" title="人气">
                            &#xe60b;
                        </i>
                        <?php echo $ques['view_num'] ?>
                    </div>
                </div>
                <div class="detail-about">
                    <a class="jie-user" href="/u/5086200/">
                        <img src="__ROOT__<?php echo $ques['face'] ?>">
                        <cite>
                           <?php echo $ques['nickname'] ?>
                            <em>
                                <?php echo Ctime($ques['create_time']) ?>
                            </em>
                        </cite>
                    </a>
                    <div class="detail-hits" id="LAY_jieAdmin" data-id="10499">
                        <span style="color:#FF7200">
                            悬赏：<?php echo $ques['kiss'] ?>飞吻
                        </span>
                        <?php if (isset($_SESSION['uid'])) { ?>
                                <?php if (isset($ques['is_coll'])) { ?>
                                    <span qid="<?php echo $ques['id'] ?>"  id="collect" class="layui-btn layui-btn-mini jie-admin layui-btn-danger" type="collect" data-type="remove">
                                    取消收藏
                                    </span>
                               <?php }else{ ?>
                                     <span qid="<?php echo $ques['id'] ?>"  id="collect" class="layui-btn layui-btn-mini jie-admin" type="collect" data-type="remove">
                                    收藏
                                    </span>
                               <?php } ?>
                            
                        <?php } ?>
                       
                    </div>
                </div>
                <div class="detail-body photos">
                   <?php echo htmlspecialchars_decode( $ques['content']) ?>
                </div>
            </div>
            <div class="fly-panel detail-box" style="padding-top: 0;">        
                <ul class="jieda photos" id="jieda"> 

            <?php foreach ($arranwer as $k => $v) { ?>
                
          
             <li data-id="8343">
                    <a name="item-1462945730182">
                    </a>
                    <div class="detail-about detail-about-reply">
                        <a class="jie-user" href="/u/660240/">
                            <img src="__ROOT__<?php echo $v['face'] ?>" alt="漂流幻境" layer-index="4">
                            <cite>
                                <i>
                                    <?php echo $v['nickname'] ?>
                                </i>
                            </cite>
                        </a>
                        <div class="detail-hits">
                            <span>
                                <?php echo Ctime($v['create_time']) ?>
                            </span>
                        </div>
                    </div>
                    <div class="detail-body jieda-body">
                           <?php echo $v['content'] ?>
                        
                    </div>
                    <!-- 点赞 -->
                   <div class="jieda-reply">
                        <span class="jieda-zan 
                        <?php if ($v['is_zan']) {

                                echo "zanok"; 
                                
                                } ?> 

                                " aid='<?php echo $v['id'] ?>' type="zan">
                            <i class="iconfont icon-zan">
                            </i>
                            <em>
                                <?php echo $v['zan_num'] ?>
                            </em>
                        </span>
                        
                        <span class="reply" nickname="<?php echo $v['nickname'] ?>" type="reply">
                            <i class="iconfont icon-svgmoban53">
                            </i>
                            <!-- a这里加一个锚点跳到提交哪里 -->
                            <a href="#comment">回复</a>
                        </span>
                        <?php if ($ques['status']=='0' and $ques['uid']==$_SESSION['uid']) { ?>
                            <div class="jieda-admin" >
                                <span class="caina" qid="<?php echo $ques['id'] ?>"  aid='<?php echo $v['id'] ?>'>采纳</span>
                            </div>
                        <?php } ?>
                    </div>
                    <?php if($v['status']!=0){ ?>
                        <i class="iconfont icon-caina" title="最佳答案" style="top:40px;"></i>
                    <?php } ?>
                    
                </li>
                <?php  } ?>
                </ul>
                     
           
            <div class="detail-about detail-about-reply">  
                <div class="layui-form layui-form-pane">
                    <form action="/jie/reply/" method="post">
                        <div class="layui-form-item layui-form-text">
                            <a name="comment">
                            </a>
                            <div class="layui-input-block">
                                <textarea id="L_content" name="content" 
                                placeholder="我要回答" class="layui-textarea fly-editor" style="height: 150px;">
                                </textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <input type="hidden" name="qid" value="<?php echo $id ?>">
                            
                            <button class="layui-btn" lay-filter="answer" lay-submit>
                                提交回答
                            </button>
                            
                        </div>
                    </form>
                </div>
            </div>
         </div>
    </div>
    </div>
    <div class="edge">
           <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                最近热帖
            </dt>
            <?php foreach ($hotview as $row) { ?>
                 <dd>
                <a href="{:U('index/jie/index',array('id'=>$row['id']))}">
                    <?php echo $row['title'] ?>
                </a>
                <span>
                    <i class="iconfont">
                        &#xe60b;
                    </i>
                    <?php echo $row['view_num'] ?>
                </span>
            </dd>
           <?php } ?>
           
           </dl>
      
        <dl class="fly-panel fly-list-one">
            <dt class="fly-panel-title">
                近期热议
            </dt>
            <?php foreach ($hotanswer as $anrow) { ?>
                <dd>
                    <a href="{:U('index/jie/index',array('id'=>$anrow['id']))}">
                        <?php echo $anrow['title'] ?>
                    </a>
                    <span>
                        <i class="iconfont">
                            &#xe60c;
                        </i>
                        <?php echo $anrow['answer_num'] ?>
                    </span>
                </dd>
          <?php  } ?>
        
        </dl>
     
    </div>
</div>
<script type="text/javascript">
 //一般直接写在一个js文件中
   layui.use(['layer','form','jquery','layedit'], function(){
      
        var layer = layui.layer;
        var form = layui.form();
        var $ = layui.jquery;
        var layedit = layui.layedit;
        //     //图片上传接口
        //     layedit.set({
        //       uploadImage: {
        //         url: '{:U('index/jie/upload')}' //接口url
        //         ,type: '' //默认post
        //       }
        //     });

        index = layedit.build('L_content'); //建立编辑器

        // //监听提交
        form.on('submit(answer)', function(data){
            
            content = layedit.getContent(index);

            if(content.length<5){
                layer.msg("内容不能少于5长度");
                return false;
            }
            data.field.content=content;
            // 发异步
            $.ajax({
                url: '{:U('index/jie/answer')}',//异步地址
                type: 'POST',
                dataType: 'json',
                data: data.field,//发送的数据
            })
            .done(function(respones) {
                //失败
                if(respones.error==1){
                    // 把失败信息弹出
                    layer.msg(respones.info, function(){});
                }else{
                    //把成功信息弹出，并中转到**页面
                    
                        location.reload();
                    
                }
            })
            .fail(function() {
                console.log("error");
            })
            
            return false;
        });
//--------------------------抓-点赞-发异步--------------------------------------------------
        $(".jieda-zan").click(function(event) {

            obj=$(this);

            aid=$(this).attr('aid');

           $.ajax({
               url: '{:U('index/jie/jiezan')}',//异步地址
                type: 'POST',
                dataType: 'json',
                data: {aid:aid},//发送的数据
           })
           .done(function(respones) {
                //失败
               if (respones.error==1) {
                num=obj.find('em').html();
                obj.find('em').html(parseInt(num)-1);
                obj.removeClass('zanok');
                //成功
               }else{
                num=obj.find('em').html();
                obj.find('em').html(parseInt(num)+1);
                obj.addClass('zanok');
               };
           })
           .fail(function() {
               console.log("error");
           })
           
        });
//------------------------------抓-收藏-发异步----------------------------------------------
        $("#collect").click(function(event) {
            qid=$(this).attr('qid');
            // alert(444);
            $.ajax({
                url:'{:U('index/jie/collect')}',
                type:'POST',
                dataType:'json',
                data: {qid:qid},
            })
            .done(function(respones) {
               if (respones.error==0) {
                    $("#collect").html('取消收藏').addClass('layui-btn-danger');
               }else{
                     $('#collect').html('收藏').removeClass('layui-btn-danger');
               };
            })          
        });
//---------------------------------@回复--------------------------------------------------------
        $(".reply").click(function(event) {
            nickname=$(this).attr('nickname');
            content = layedit.getContent(index);
            nickname="@"+nickname+" ";
            str="@"+'<a href="/jump?username='+nickname+'" class="fly-aite" target="_blank">'+nickname+'</a>';
            content+=nickname;
           layedit.setContent(index,content);

        });
//-----------------采纳---------完成--------------------------

        $(".caina").click(function(event) {
            // alert(88);
           qid=$(this).attr('qid');
           aid=$(this).attr('aid');
            // alert(444);
            $.ajax({
                url:'{:U('index/jie/status')}',
                type:'POST',
                dataType:'json',
                data: {qid:qid,aid:aid},
            })
            .done(function(respones) {
                if(respones.error==1){
                    // 把失败信息弹出
                    layer.msg(respones.info, function(){});
                }else{

                    location.reload();
                }
            })          
        
        });


    });  
    


</script>